package com.uestc.util;

import java.util.Calendar;
import java.util.Date;
import java.sql.Timestamp;

public class TimeUtil {
	
	/**
	 * 获得系统当前时间
	 * @return
	 */
	public static Timestamp getDateTime(){
		Date date = new Date();
		return new Timestamp(date.getTime());
	}
	
	/**
	 * 进行时间相加
	 * @param days 天数
	 * @return 返回时间相加后的天数
	 */
	public static Timestamp addDate(int days){
		Calendar calendar = Calendar.getInstance();
		calendar.add(Calendar.DATE, days);
		Date date = calendar.getTime();
		return new Timestamp(date.getTime());
	}
	
	/**
	 * 比较时间
	 * @param time1 
	 * @param time2 
	 * @return
	 */
	public static int compareDate(Timestamp time1, Timestamp time2){
		return time1.compareTo(time2);
	}
}